Skip to content

Conversation

jhawthorn
Copy link
Member

Fixes #1319 (I wanted this for exactly that reason 😅)

Automatically start searching when ?q= parameter is given in the URL, selecting and visiting the first match if available.

If not available, the query will be filled into the search box but we won't navigate away.

This should enable configuring a generated rdoc page as a search engine in one's web browser, or as a bang command in a search engine. For reference Rails' sdoc (which I think rdoc's search is originally based on) does this: https://api.rubyonrails.org/?q=changed%3F

Automatically start searching when ?q= parameter is given in the URL,
selecting and visiting the first match if available.

If not available, the query will be filled into the search box but we
won't navigate away.
@jhawthorn jhawthorn temporarily deployed to fork-preview-protection July 29, 2025 23:11 — with GitHub Actions Inactive
@matzbot
Copy link
Collaborator

matzbot commented Aug 3, 2025

🚀 Preview deployment available at: https://28a79875.rdoc-6cd.pages.dev (commit: df0cf11)

@st0012 st0012 self-requested a review August 4, 2025 00:07
@st0012
Copy link
Member

st0012 commented Aug 4, 2025

Accepting ?q= will be a big improvement ❤️
But is it possible to keep the search results open even after jumping like SDoc does?
If that's too complicated (I tried it a bit but failed) due to how darkfish works, I'd prefer not jumping immediately (or only jump when there's exactly one result), so we can show the results dropdown.

@jhawthorn jhawthorn temporarily deployed to fork-preview-protection August 14, 2025 00:31 — with GitHub Actions Inactive
@jhawthorn
Copy link
Member Author

But is it possible to keep the search results open even after jumping like SDoc does?

SDoc does this using turbolinks, which I think works extremely well in the docs, but is a bit more than I wanted to do in this PR.

How's this? I made it so that the page we jump to is given ?q=<search>&nav=0, and we use that second parameter to disable the "feeling lucky".

Copy link
Member

@st0012 st0012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks!

@st0012
Copy link
Member

st0012 commented Aug 14, 2025

CI failure is unrelated.

@st0012 st0012 merged commit 069fbf6 into ruby:master Aug 14, 2025
32 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for reading search term from query param
3 participants